package com.qf.efserver.sleep.controller;

import com.qf.common.core.annotation.NoLoginCheck;
import com.qf.common.core.common.R;
import com.qf.common.core.entity.SleepTime;
import com.qf.efserver.alarm.param.AlarmParam;
import com.qf.efserver.alarm.service.AlarmService;
import com.qf.efserver.sleep.param.SleepParam;
import com.qf.efserver.sleep.service.SleepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sleep")
@Api(tags = "睡眠模块")
public class SleepController {

@Resource
private SleepService sleepService;

    @PostMapping("/addSleep")
    @ApiOperation(value = "添加睡眠记录")
    public R addAlarm(@RequestBody SleepParam param){

        sleepService.addSleep(param);
        return R.ok("闹钟设置成功");
    }

@ApiOperation(value = "查询当前用户睡眠状态和睡眠时长")
    @GetMapping("/sleepTime")
    public  R  selectSleepTimeByUserId(){
        SleepTime sleepTime = sleepService.selectSleepByUserId();

        return  R.ok("查询成功",sleepTime);
    }

}
